package com.bdqn.controller;


import com.bdqn.entity.allParams.PmsCommentParam;
import com.bdqn.entity.PmsComment;
import com.bdqn.entity.util.RespBean;
import com.bdqn.service.PmsCommentService;
import com.bdqn.util.PageDto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 商品评价表 前端控制器
 * </p>
 *
 * @author hunter
 * @since 2022-04-30
 */
@RestController
@RequestMapping("/pms/comment")
public class PmsCommentController {
    @Autowired
    private PmsCommentService pmsCommentService;

    @PostMapping("/postComment")
    public RespBean postComment(PmsComment pmsComment){
//        pmsCommentService.pmsAddComment(pmsAddCommentParam);
         if(pmsCommentService.save(pmsComment)){
             return RespBean.ok("成功",null);
         }else {
              return RespBean.err("失败");
         }

    }
    @GetMapping("/commentList")
    public RespBean commentList(PmsCommentParam pmsCommentParam){
        System.out.println("获取的参数"+pmsCommentParam);
        PageDto<PmsComment> pmsCommentPageDto = pmsCommentService.pmsCommentDto(pmsCommentParam);
        if(pmsCommentPageDto!=null){
            return RespBean.ok("获取商品评价列表成功",pmsCommentPageDto);
        }else {
            return RespBean.err("获取商品评价列表失败");
        }

    }
}
